/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.dataInterface;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.UploadUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.acq.entity.areainfo.AcqAreaInfo;
import com.thinkgem.jeesite.modules.acq.service.areainfo.AcqAreaInfoService;

import groovy.transform.Synchronized;

/**
 * 形成区域接口
 * @author lj
 * @version 2018-3-20
 */
@Controller
@RequestMapping(value = "")
public class AreaInfoController extends BaseController {
	@Autowired AcqAreaInfoService service;
	// 保存行政区介绍信息
	@RequestMapping(value = "saveAreaInfo")
	@ResponseBody
	public Map<String,Object> saveAreaInfo(AcqAreaInfo acqAreaInfo,HttpServletRequest request, HttpServletResponse response, String id) {
		String	relativePath = Global.getConfig("envphotos");
		String remote = acqAreaInfo.getPhoto().replaceAll("_downloads", "/proDataAcq/"+relativePath+"/"+new SimpleDateFormat("yyyyMMdd").format(new Date())) ;
		acqAreaInfo.setPhoto(remote);
		return service.saveAreaInfo(acqAreaInfo);
	}
	
	
	/*
	 * 保存照片信息
	 */
	@RequestMapping(value = "/uploadEnv", method = RequestMethod.POST)
	@Synchronized
	@ResponseBody
	public String uploadEnv(HttpServletRequest request) {
		
		
		UploadUtils upload = new UploadUtils();
		upload.uploadFile(request, Global.getConfig("envphotos"));
		
	
			return "1";
	}
	
	//uploadEnv
	

}
